<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <ul id="myList"></ul>

  <script>
    let fragment = document.createDocumentFragment();
    let ul = document.getElementById('myList');

    for (let i = 0; i < 3; i++) {
      let li = document.createElement('li');
      li.appendChild(document.createTextNode(`Item ${i + 1}`));
      fragment.appendChild(li);
    }

    // 一次性把 li 添加到 ul 中，不用重复添加三次
    ul.appendChild(fragment);
  </script>
</body>
</html>